import { IPSAppDEUILogicLink } from '../../app/dataentity/ipsapp-deuilogic-link';
import { IPSDEUILogic } from './ipsdeuilogic';
import { IPSDEUILogicLink } from './ipsdeuilogic-link';
import { IPSDEUILogicLinkGroupCond } from './ipsdeuilogic-link-group-cond';
import { IPSDEUILogicNode } from './ipsdeuilogic-node';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEUILogicLinkImpl extends PSModelObjectImpl implements IPSDEUILogicLink, IPSAppDEUILogicLink {
  get codeName(): string {
    return this.M.codeName;
  }

  protected dstpsdeuilogicnode: IPSDEUILogicNode | null = null;

  getDstPSDEUILogicNode(): IPSDEUILogicNode | null {
    if (this.dstpsdeuilogicnode != null) return this.dstpsdeuilogicnode;
    const value = this.M.getDstPSDEUILogicNode;
    if (value == null) {
      return null;
    }
    const ipsdeuilogic = this.getParentPSModelObject('dataentity.logic.IPSDEUILogic') as IPSDEUILogic;
    if (ipsdeuilogic != null) {
      this.dstpsdeuilogicnode = ipsdeuilogic.findPSDEUILogicNode(value);
    }
    return this.dstpsdeuilogicnode;
  }

  get dstPSDEUILogicNode(): IPSDEUILogicNode | null {
    return this.getDstPSDEUILogicNode();
  }

  getDstPSDEUILogicNodeMust(): IPSDEUILogicNode {
    const value = this.getDstPSDEUILogicNode();
    if (value == null) {
      throw new Error('未指定目标逻辑节点对象');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get linkCond(): string {
    return this.M.linkCond;
  }

  get linkMode(): 0 | 1 | 2 | 3 | 9 {
    return this.M.linkMode;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdeuilogiclinkgroupcond: IPSDEUILogicLinkGroupCond | null = null;

  getPSDEUILogicLinkGroupCond(): IPSDEUILogicLinkGroupCond | null {
    if (this.psdeuilogiclinkgroupcond != null) return this.psdeuilogiclinkgroupcond;
    const value = this.M.getPSDEUILogicLinkGroupCond;
    if (value == null) {
      return null;
    }
    this.psdeuilogiclinkgroupcond = this.getPSModel4('dataentity.logic.IPSDEUILogicLinkGroupCond', value, 'getPSDEUILogicLinkGroupCond') as IPSDEUILogicLinkGroupCond;
    return this.psdeuilogiclinkgroupcond;
  }

  get psDEUILogicLinkGroupCond(): IPSDEUILogicLinkGroupCond | null {
    return this.getPSDEUILogicLinkGroupCond();
  }

  getPSDEUILogicLinkGroupCondMust(): IPSDEUILogicLinkGroupCond {
    const value = this.getPSDEUILogicLinkGroupCond();
    if (value == null) {
      throw new Error('未指定连接条件对象');
    }
    return value;
  }

  protected srcpsdeuilogicnode: IPSDEUILogicNode | null = null;

  getSrcPSDEUILogicNode(): IPSDEUILogicNode | null {
    if (this.srcpsdeuilogicnode != null) return this.srcpsdeuilogicnode;
    const value = this.M.getSrcPSDEUILogicNode;
    if (value == null) {
      return null;
    }
    const ipsdeuilogic = this.getParentPSModelObject('dataentity.logic.IPSDEUILogic') as IPSDEUILogic;
    if (ipsdeuilogic != null) {
      this.srcpsdeuilogicnode = ipsdeuilogic.findPSDEUILogicNode(value);
    }
    return this.srcpsdeuilogicnode;
  }

  get srcPSDEUILogicNode(): IPSDEUILogicNode | null {
    return this.getSrcPSDEUILogicNode();
  }

  getSrcPSDEUILogicNodeMust(): IPSDEUILogicNode {
    const value = this.getSrcPSDEUILogicNode();
    if (value == null) {
      throw new Error('未指定源逻辑节点对象');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get catchLink(): boolean {
    return this.M.catchLink != null ? this.M.catchLink : false;
  }

  get defaultLink(): boolean {
    return this.M.defaultLink != null ? this.M.defaultLink : false;
  }

  get fulfilledLink(): boolean {
    return this.M.fulfilledLink != null ? this.M.fulfilledLink : false;
  }

  get rejectedLink(): boolean {
    return this.M.rejectedLink != null ? this.M.rejectedLink : false;
  }

  get subCallLink(): boolean {
    return this.M.subCallLink != null ? this.M.subCallLink : false;
  }

  get cls(): string {
    return 'PSDEUILogicLinkImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEUILogicLink' || cls == 'dataentity.logic.IPSDEUILogicLink') return true;
    return super.instanceof(cls);
  }
}
